package com.honey.mybatis.generator.condition.method;

import com.honey.compilation.java.Clazz;
import com.honey.compilation.java.JavaKeyWord;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.mybatis.generator.AbstractMethod;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.condition.ConditionConstant;
import com.honey.mybatis.generator.criteria.CriteriaConstant;

/**
 * clear 函数
 * @author Administrator
 *
 */
public class ClearMethod extends AbstractMethod {
	
	public ClearMethod(){
	}
	public ClearMethod(Clazz clazz, MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(clazz, belongPlugin, introspectSchema, introspectSchemaColumn);
	}
	
	private static final String METHOD_NAME ="clear";
	
	private static final String[] METHOD_BODY =new String[]{
		
		JavaKeyWord.OPERATION_THIS + ConditionConstant.ORED_CRITERIA+".clear()",
		
		JavaKeyWord.OPERATION_THIS + ConditionConstant.GENERATED_CRITERIA + "." +CriteriaConstant.GET_ALL_CRITERIA + "().clear()",
		
		JavaKeyWord.OPERATION_THIS + ConditionConstant.SORT +" = null",
		
		JavaKeyWord.OPERATION_THIS + ConditionConstant.DISTINCT +" = false"
	};
	
	private static final String[] JAVA_DOC = new String []{
		"清除当前的查询条件环境。"
	};
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getMethodName()
	 */
	@Override
	protected String getMethodName() {
		return METHOD_NAME;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getBody()
	 */
	@Override
	protected String[] getBody() {
		return METHOD_BODY;
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getJavaDoc()
	 */
	@Override
	protected String[] getJavaDoc() {
		return JAVA_DOC;
	}
	
	public static void main(String []args){
		ClearMethod  cm = new ClearMethod();
		System.out.println(cm.createMethod().compiledContent(0)); 
	}
}
